package com.bw.aop;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class Myaop {


    @Around("execution(* com.bw.controller.*.*(..))")
    public Object aop(ProceedingJoinPoint joinPoint) throws Throwable {

        System.out.println("方法名" + joinPoint.getSignature().getName());
        System.out.println("入参" + joinPoint.getArgs());
        System.out.println("入参" + JSON.toJSONString(joinPoint.getArgs(), SerializerFeature.IgnoreNonFieldGetter));
        long l = System.currentTimeMillis();

        Object proceed = joinPoint.proceed();

        long l2 = System.currentTimeMillis();
        System.out.println("耗时 " + (l2 - l));
        System.out.println("返回值 " + proceed);
        return proceed;
    }
}
